﻿package mortal.game.view.shopMall
{
    import Message.DB.Tables.*;
    import Message.Game.*;
    import flash.utils.*;
    import mortal.game.resource.tableConfig.*;
    import mortal.game.view.shopMall.data.*;

    public class ShopCache extends Object
    {
        public var buyRecords:Dictionary;
        public var buyBackList:Array;
        public var lastPanicShopCode:int;
        public var lastPanBuyTime:Date;
        public var notToRemind:Boolean;
        public var rebateInfoDic:Dictionary;
        public var curShopId:int = -1;

        public function ShopCache()
        {
            this.buyRecords = new Dictionary();
            this.buyBackList = new Array();
            this.rebateInfoDic = new Dictionary();
            return;
        }// end function

        public function updateGoodsRemainNum(param1:SOnsellItemsMsg) : void
        {
            var _loc_4:SOnSellItem = null;
            if (param1 == null)
            {
                return;
            }
            this.curShopId = param1.shopCode;
            var _loc_2:* = param1.items;
            var _loc_3:int = 0;
            while (_loc_3 < _loc_2.length)
            {
                
                _loc_4 = _loc_2[_loc_3];
                if (this.rebateInfoDic[this.curShopId + "_" + _loc_4.itemCode] == null)
                {
                    this.rebateInfoDic[this.curShopId + "_" + _loc_4.itemCode] = new RebateItemData();
                }
                (this.rebateInfoDic[this.curShopId + "_" + _loc_4.itemCode] as RebateItemData).remainInfo = _loc_4;
                _loc_3++;
            }
            return;
        }// end function

        public function updatePlayerBuyNum(param1:SOnSellItemsPlayerMsg) : void
        {
            var _loc_4:SOnSellItemPlayer = null;
            if (param1 == null)
            {
                return;
            }
            this.curShopId = param1.shopCode;
            var _loc_2:* = param1.buyShop;
            var _loc_3:int = 0;
            while (_loc_3 < _loc_2.length)
            {
                
                _loc_4 = _loc_2[_loc_3];
                if (this.rebateInfoDic[this.curShopId + "_" + _loc_4.itemCode] == null)
                {
                    this.rebateInfoDic[this.curShopId + "_" + _loc_4.itemCode] = new RebateItemData();
                }
                (this.rebateInfoDic[this.curShopId + "_" + _loc_4.itemCode] as RebateItemData).playerInfo = _loc_4;
                _loc_3++;
            }
            return;
        }// end function

        public function get isHasGetServerPanicInfo() : Boolean
        {
            var _loc_2:Boolean = false;
            var _loc_3:TShopPanicBuyItem = null;
            var _loc_4:RebateItemData = null;
            var _loc_1:* = ShopConfig.instance.rebateShopMap[this.curShopId];
            if (_loc_1 && _loc_1.length)
            {
                _loc_3 = _loc_1[0] as TShopPanicBuyItem;
                _loc_4 = this.getRebateInfoDicByItemCode(_loc_3.itemCode);
                if (_loc_4 && _loc_4.remainInfo)
                {
                    _loc_2 = true;
                }
            }
            return _loc_2;
        }// end function

        public function isGetRebatInfoByItemCode(param1:int) : Boolean
        {
            var _loc_2:* = this.rebateInfoDic[this.curShopId + "_" + param1];
            return _loc_2 && _loc_2.remainInfo;
        }// end function

        public function getRebateInfoDicByItemCode(param1:int) : RebateItemData
        {
            return this.rebateInfoDic[this.curShopId + "_" + param1];
        }// end function

        public function removeBuyBackItemByUid(param1:String) : void
        {
            var _loc_2:int = 0;
            while (_loc_2 < this.buyBackList.length)
            {
                
                if (this.buyBackList[_loc_2].uid == param1)
                {
                    this.buyBackList.splice(_loc_2, 1);
                }
                _loc_2++;
            }
            return;
        }// end function

    }
}
